package tech.youai.ppping;

import org.springframework.util.StringUtils;

public class PingResult {
    private Throwable exception;
    private boolean success;
    private String message;

    public void setException(Throwable exception) {
        this.exception = exception;
    }

    public Throwable getException() {
        return exception;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMessage() {
        if(StringUtils.hasLength(this.message)){
            return this.message;
        }
        if(this.exception!=null){
            return this.exception.getMessage();
        }
        return null;
    }
}
